<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>密码修改</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.">
<link rel="stylesheet" href="lib/weui.min.css">
<link rel="stylesheet" href="css/jquery-weui.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body ontouchstart>
<!--主体-->
<header class="wy-header">
  <div class="wy-header-icon-back" onclick="back();"><span></span></div>
  <div class="wy-header-title">密码修改</div>
</header>
<FORM action="psd_change.htm" METHOD="post" id="sbumitq">
<div class="weui-content">
  <div class="weui-cells weui-cells_form wy-address-edit">

    <div class="weui-cell weui-cell_vcode">
      <div class="weui-cell__hd"><label class="weui-label wy-lab">手机号</label></div>
      <div class="weui-cell__bd"><input class="weui-input" type="tel" placeholder="请输入手机号" id="phone"  name="phone"></div>
      <div class="weui-cell__ft"><div  style="cursor: pointer" class="weui-vcode-btn" onclick="bcd();">获取验证码</div></div>
    </div>
    <div class="weui-cell" style="display:none;" id="t1"><div id="phone01" style="color: red"></div></div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label wy-lab">验证码</label></div>
      <div class="weui-cell__bd"><input class="weui-input" type="number" placeholder="请输入验证码" id="yanz"></div>
    </div>
    <div class="weui-cell" style="display:none;" id="t2"><div id="yanz2" style="color: red"></div></div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label wy-lab">新密码</label></div>
      <div class="weui-cell__bd"><input class="weui-input" type="number" pattern="[0-9]*" placeholder="请输入新密码" id="pwd01"></div>
    </div>
    <div class="weui-cell" style="display:none;"  id="t3"><div id="pwd2" style="color: red"></div></div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label wy-lab">确认密码</label></div>
      <div class="weui-cell__bd"><input class="weui-input" type="number" pattern="[0-9]*" placeholder="请再次输入新密码" name="password" id="pwd02"></div>
    </div>
    <div class="weui-cell" style="display:none;"  id="t4"><div id="pwd1" style="color: red"></div></div>
  </div>
  <div class="weui-btn-area"><a href="javascript:;" class="weui-btn weui-btn_primary" onclick="cdf();">确认修改</a></div>
</div>
</FORM>
<script src="lib/jquery-2.1.4.js"></script> 
<script src="lib/fastclick.js"></script> 
<script type="text/javascript" src="js/jquery.Spinner.js"></script>
<script type="text/javascript" src="js/jquery-form.js"></script>
<script type="text/javascript" src="js/layer/layer.js"></script>
<script>
  $(function() {
    FastClick.attach(document.body);
  });
  var xcode;
  function bcd() {
      var phone=$("#phone").val();
      if(phone==null || phone==""){
          $("#t1").show();
          $("#phone01").html("电话不能为空！");
          return;
      }
      var reg = /^1[0-9]{10}$/;
      if(!reg.test(phone)){
          $("#t1").show();
          $("#phone01").html("电话号码不正确！");
          return;
      }
      jQuery.ajax({
          url:"ceshi.htm",
          data:{"phone":phone},
          type:"post",
          success:function(message){
              if(message == 2){
                  $("#t1").show();
                  $("#phone01").html("该电话号码未注册！");
              }else{
                  jQuery.ajax({
                      url:"duanxin01.htm",
                      data:{"phone":phone},
                      type:"post",
                      success:function(message01){
                          if(message01 == 1){
                              $("#phone01").html("验证码发送失败，请检查手机号码！");
                          }else{
                              layer.msg("已发送！");
                              xcode=message01;
                          }
                      },
                      error:function(){
                          alert("error!");
                      }
                  });
              }
          },
          error:function(){
              alert("error!");
          }
      });
  }

  function cdf(){
      var phone=$("#phone").val();
      if(phone==null || phone==""){
          $("#t1").show();
          $("#phone01").html("电话不能为空！");
          return;
      }
      var yanz=$("#yanz").val();
      var reg1 = /^[0-9]{6}$/;
      if(!reg1.test(yanz)||yanz!=xcode){
          $("#t2").show();
          $("#yanz2").html("验证码号码不正确！");
          return;
      }
      var pwd01=$("#pwd01").val();
      if(pwd01==null||pwd01==""){
          $("#t3").show();
          $("#pwd2").html("密码不能为空！");
      }
      var pwd02=$("#pwd02").val();
      if (pwd01 == pwd02){
          flag02=true;
      }else{
          $("#t4").show();
          $("#pwd1").html("两次密码输入不一致！");
          return;
      }

     // $("#sbumitq").submit();
      var form=$("#sbumitq");
      var options={
          url:"psd_change.htm",
          type:"post",
          success: function (message) {
              debugger;
              //var succ=JSON.parse(message).succ;
              if(message=="1"){
                  layer.msg("修改成功！跳转到登陆页面");
                  window.location.href="login.htm";
              }else{
                  layer.msg("修改失败！");
                  window.location.reload();
              }
          },
          clearForm:true, //提交成功后是否清空表单中的字段值
          restForm:true, //提交成功后是否重置表单中的字段值，即恢复到页面加载时的状态
      };
      form.ajaxSubmit(options);
  }
  function back() {
      window.location.href=document.referrer;
  }
</script>

<script src="js/jquery-weui.js"></script>
</body>
</html>
